package com.jxpanda.spring.module.auth.endpoint.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.oauth2.core.OAuth2Error;
import reactor.core.publisher.Mono;

public interface ReactiveAuthenticationFailureHandler {

    Logger logger = LoggerFactory.getLogger(ReactiveAuthenticationFailureHandler.class);

    default Logger getLogger() {
        return logger;
    }

    default Mono<Object> onAuthenticationFailure(Throwable throwable) {
        getLogger().error("【ERROR】", throwable);
        OAuth2Error oAuth2Error = new OAuth2Error(throwable.getMessage());
        return Mono.justOrEmpty(oAuth2Error);
    }

}
